module.exports = {
	data() {
		return {
			form: {
				lat: '',
				lng: '',
			},
			// 上传图片配置
			setting: {
				sourceType: [],
				showUploadList: true

			},
			photo: '',
			photos: [],
			action: this.$api.upload.index,
			formData: {},
			isopencar: false,
			// #ifdef MP-WEIXIN
			isdd: false,
			// #endif
			// #ifdef H5
			isdd: true,
			// #endif
		}
	},

	onLoad() {

	},
	onShow() {
		if (this.isopencar == true) {
			this.closeloading()
		}
		let printlist = this.$storage.getStorageSync('printlist');
		let cklist = this.$storage.getStorageSync('cklist');

		if (!cklist || cklist.length < 1) {
			this.getWarehouseList();
		}
		if (!printlist || printlist.length < 1) {
			this.getPrintList()
		}
		//获取位置信息
		// this.getLocation()
	},
	methods: {

		getWarehouseList() {
			let that = this;
			that.$request({
				url: that.$api.common.warehouse,
				data: {}
			}).then(response => {
				if (response.code === 0) {
					console.log(response)
					that.$storage.setStorageSync('cklist', response.list)
				}
			}).catch((msg) => {
				this.$t.message.toast(msg);
				this.$t.message.closeLoading();
			});
		},
		showloading() {
			this.isopencar = true
			this.$t.message.loading('处理中')
		},
		closeloading() {
			this.isopencar = false
			this.$t.message.closeLoading()
		},

		uperror(e) {
			this.$t.message.toast(e.msg)
		},

		upchange(e) {

		},
		//获取经纬度
		getLocation() {

		},
		getPrintList() {
			let t = this;
			console.log("获取打印机列表")
			t.$request({
				url: t.$api.print.list,
				data: {
					limit_page: 1,
					limit_count: 100,
				}
			}).then(response => {
				if (response.code === 0) {
					t.$storage.setStorageSync('printlist', response.list)
				}
			}).catch((msg) => {
				t.$t.message.toast(msg);
				t.$t.message.closeLoading();
			});
		},
		goBack() {
			// 通过判断当前页面的页面栈信息，是否有上一页进行返回，如果没有则跳转到首页
			const pages = getCurrentPages()
			if (pages && pages.length > 0) {
				const firstPage = pages[0]
				if (pages.length == 1 && (!firstPage.route || firstPage.route != 'pages/index')) {
					uni.reLaunch({
						url: '/pages/index'
					})
				} else {
					uni.navigateBack({
						delta: 1
					})
				}
			} else {
				uni.reLaunch({
					url: '/pages/index'
				})
			}
		},
	}
}